﻿#region Header
//************************************************************************************
// Name: FileSystemDao
// Description: 
// Created On:  27-Dec-2011
// Created By:  Swathi
// Last Modified On:
// Last Modified By: 
// Last Modified Reason: 
//*************************************************************************************
#endregion Header
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Base.Common;
using System.Collections;
using System.IO;

namespace Base.Document
{
    public class ConcreteFileSystemDao :IDmsDao 
    {
        /// <summary>
        /// Retrives the files from specified directory
        /// </summary>
        /// <param name="dirPath"></param>
        /// <returns></returns>
        public FileInfo[] GetFiles(string dirPath)
        {
            //get the directory info by passing the directory path
            var di = new DirectoryInfo(dirPath);
            //get files from directory
            var files = di.GetFiles();
            //return files
            return files;
        }
        public void CommitChanges()
        {
            //mongo isn't transactional in this way
        }

        public void Delete<T>(System.Linq.Expressions.Expression<Func<T, bool>> expression) where T : class, new()
        {
            var items = All<T>().Where(expression);
            foreach (T item in items)
            {
                Delete(item);
            }
        }

        public void Delete<T>(T item) where T : class, new()
        {
            throw new NotImplementedException();

        }

        public void DeleteAll<T>() where T : class, new()
        {
            throw new NotImplementedException();
        }
        public T Single<T>(System.Linq.Expressions.Expression<Func<T, bool>> expression) where T : class, new()
        {
            return All<T>().Where(expression).SingleOrDefault();
        }

        public IQueryable<T> All<T>() where T : class, new()
        {
            throw new NotImplementedException();
        }

        public void Add<T>(T item) where T : class, new()
        {
            throw new NotImplementedException();
        }



        public void Add<T>(IEnumerable<T> items) where T : class, new()
        {
            foreach (T item in items)
            {
                Add(item);
            }
        }

        public void Update<T>(T item) where T : class, new()
        {
            throw new NotImplementedException();
        }
        //Helper for using map reduce in mongo
        public T MapReduce<T>(string map, string reduce)
        {
            throw new NotImplementedException();
            
        }

      
        public void Dispose()
        {
            throw new NotImplementedException();
        }   
    }
}
